# cython: language_level=3
"""
-- xndx_down_test.resource definition

CREATE TABLE `resource` (
  `resource_id` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '资源id',
  `resource_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '名称',
  `resource_type` int NOT NULL DEFAULT '1' COMMENT '资源类型 1-发电资源 2-储电资源 3-用电资源',
  `resource_state` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '资源状态（测试、投运、停机、退役）',
  `max_adjustable_power` int DEFAULT '0' COMMENT '最大可调节功率',
  `assessment_meterbox` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '供电局总电表的资产编码，如果多块电表用逗号隔开，如： M394374,M484574 ',
  `listing_num` varchar(60) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '配变挂牌号',
  `rated_capacity` int DEFAULT '0' COMMENT '变电容量，单位kW',
  `rated_power` int DEFAULT '0' COMMENT '额定功率（kW）',
  `rated_voltage` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '额定电压，单位kV',
  `longitude` decimal(12,6) NOT NULL DEFAULT '0.000000' COMMENT '经度  采用百度地图坐标系 保留小数点后6位',
  `latitude` decimal(12,6) NOT NULL COMMENT '纬度  采用百度地图坐标系 保留小数点后6位',
  `parent_resource_id` int NOT NULL DEFAULT '0' COMMENT '父parentId',
  `operator_id` int NOT NULL DEFAULT '0' COMMENT '负荷聚合商id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`resource_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC;
"""

from datetime import datetime

from sqlalchemy import Column, Integer, String, DateTime, DECIMAL

from common.database import BaseTable


class Resource(BaseTable):
    __tablename__ = "resource"
    resource_id = Column(String(64), comment="资源id")
    resource_name = Column(String(255), comment="名称")
    resource_type = Column(
        Integer, comment="资源类型 1-发电资源 2-储电资源 3-用电资源"
    )
    resource_state = Column(
        String(60), comment="资源状态（测试、投运、停机、退役）"
    )
    max_adjustable_power = Column(Integer, comment="最大可调节功率")
    assessment_meterbox = Column(
        String(255),
        nullable=False,
        comment="供电局总电表的资产编码，如果多块电表用逗号隔开，如： M394374,M484574 ",
    )
    listing_num = Column(String(60), comment="配变挂牌号")
    rated_capacity = Column(Integer, comment="变电容量，单位kW")
    rated_power = Column(Integer, comment="额定功率（kW）")
    rated_voltage = Column(DECIMAL(10, 2), comment="额定电压，单位kV")
    longitude = Column(
        DECIMAL(12, 6),
        nullable=False,
        comment="经度  采用百度地图坐标系 保留小数点后6位",
    )
    latitude = Column(
        DECIMAL(12, 6),
        nullable=False,
        comment="纬度  采用百度地图坐标系 保留小数点后6位",
    )
    parent_resource_id = Column(String(64), comment="父parentId")
    operator_id = Column(String(64), comment="负荷聚合商id")
    create_time = Column(
        DateTime, comment="创建时间", default=datetime.now()
    )
    resource_host = Column(String(64), comment="resource host")
